#pragma once

#include "../libs/libdef.h"

#include <vector>
#include <unordered_map>

namespace lukv {

class manager {
public:
    static time_t sys_time;
    static std::vector<sockaddr_in> driver_addrs;
    static std::vector<sockaddr_in> worker_addrs;
    static int replication;
    static std::unordered_map<int, long> expire_cli_socks;
    static long max_cli_expire_time;
public:
    static int get_driver_index(const sockaddr_in &);
    static int get_worker_index(const sockaddr_in &);
    static void set_driver_addrs(const std::vector<sockaddr_in> &);
    static void set_worker_addrs(const std::vector<sockaddr_in> &);
    static void set_max_cli_expire_time(long x);
    static void set_replication(int rep);
    static bool is_node(sockaddr_in & addr);
    static void set_expire_cli(int sock);
    static void remove_expire_cli(int sock);
    static bool cli_expired(int sock);
    static std::vector<int> get_expired_clis();
};

}
